package com.example.patient.controller;

import com.example.common.entity.SysDiseaseEncyclopedia;
import com.example.common.entity.SysDiseaseEncyclopediaClassification;
import com.example.common.support.Result;
import com.example.patient.dto.resp.DiseaseListResp;
import com.example.patient.dto.resp.IMOrderListResp;
import com.example.patient.service.CyclopediaService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName CyclopediaController
 * @Author wengjt
 * @Date 2021/4/2015:45
 * @Description 疾病百科接口
 **/
@RestController
@Api(tags = "疾病百科接口")
@RequestMapping("/cyclopedia/illness")
@Slf4j
public class CyclopediaController {
    @Resource
    private CyclopediaService cyclopediaService;

    @ApiOperation(value = "获取疾病类型列表", notes = "获取疾病类型列表")
    @GetMapping(value = "/illnessTypeList")
    public Result<List<SysDiseaseEncyclopediaClassification>> getIllnessTypeList() {
        return Result.success(cyclopediaService.getIllnessTypeList());
    }

    @ApiOperation(value = "获取指定类型疾病列表", notes = "获取指定类型疾病列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "limit", value = "单页大小", paramType = "query", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "decId", value = "疾病分类id", paramType = "query", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping(value = "/diseaseList")
    public Result<DiseaseListResp> getDiseaseList(Integer limit, Integer page, Integer decId) {
        return Result.success(cyclopediaService.getDiseaseList(page, limit, decId));
    }

    @ApiOperation(value = "获取疾病百科详情", notes = "获取疾病百科详情")
    @ApiImplicitParam(name = "deId", value = "疾病id", dataTypeClass = Integer.class, required = true)
    @GetMapping(value = "disease")
    public Result<SysDiseaseEncyclopedia> getDiseaseInfo(Integer deId) {
        return Result.success(cyclopediaService.getDiseaseInfo(deId));
    }

    @ApiOperation(value = "搜索疾病百科", notes = "搜索疾病百科")
    @ApiImplicitParams(
            {@ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataTypeClass = Integer.class, required = true),
                    @ApiImplicitParam(name = "limit", value = "单页大小", paramType = "query", dataTypeClass = Integer.class, required = true),
                    @ApiImplicitParam(name = "name", value = "疾病名称", dataTypeClass = String.class, required = false)})
    @GetMapping(value = "/disease/search")
    public Result<DiseaseListResp> searchDisease(Integer page, Integer limit, String name) {
        return Result.success(cyclopediaService.searchDiseaseList(page, limit, name));
    }
}
